package com.mybatisplus.controller;

import com.mybatisplus.pojo.Teacher;
import com.mybatisplus.service.TeacherService;
import com.mybatisplus.utils.ResultOBJ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/adminapi/teachers")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @GetMapping
    public List<Teacher> getTeacherList() {
        return teacherService.getTeacherList();
    }

    @PostMapping
    public ResultOBJ addTeacher(@RequestBody Teacher teacher) {
        try {
            teacherService.addTeacher(teacher);
            return ResultOBJ.ADD_SUCCESS;
        } catch (Exception e) {
            return ResultOBJ.ADD_ERROR;
        }
    }
}
